package jco3.securityConfiguration;

import java.util.Properties;

import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.ext.DestinationDataProvider;
import com.sap.conn.jco.ext.Environment;

public class TestCustomDestinationDataProvider {
	
	public static void main(String[] args) {
		Properties connProps = new Properties();
        connProps.setProperty(DestinationDataProvider.JCO_ASHOST, "test");
        connProps.setProperty(DestinationDataProvider.JCO_SYSNR, "00");
        connProps.setProperty(DestinationDataProvider.JCO_USER, "test");
        connProps.setProperty(DestinationDataProvider.JCO_PASSWD, "test");
        connProps.setProperty(DestinationDataProvider.JCO_CLIENT, "666");
        connProps.setProperty(DestinationDataProvider.JCO_LANG, "EN");
        
        CustomDestinationDataProvider provider = new CustomDestinationDataProvider();
        provider.addDestinationProperties("SAP_CONN", connProps);
        Environment.registerDestinationDataProvider(provider);
        
        try {
			JCoDestination dest = JCoDestinationManager.getDestination("SAP_CONN");
			dest.ping();
			System.out.println("连接成功");
 		} catch (JCoException  ex) {
 			System.out.println(ex);
            System.out.println("连接失败");
		}
	}
}
